package labs.fourth;

public enum TokenType {
	INTEGER_LITERAL(1),
	FLOATING_POINT_LITERAL(2), 
	CHARACTER_LITERAL(4), 
	STRING_LITERAL(8), 
	BOOLEAN_LITERAL(16), 
	NULL_LITERAL(32), 
	FINAL_MODIFIER(64), 
	MODIFIER(128), 
	IDENTIFIER(512), 
	POSTFIX_OPERATOR(1024),
	INFIX_OPERATOR(2048),
	BASIC_TYPE(4096),
	ASSIGNMENT_OPERATOR(8192),
	PREFIX_OPERATOR(16384),
	NEUTRAL(0);
	public final int value;
	private TokenType(int value){
		this.value = value;
	}
	
	public static int getValue(TokenType... types) {
		int value = 0;
		for(TokenType type : types) {
			value |= type.value;
		}
		
		return value;
	}
	public static boolean isOfType(int value, TokenType type){
		return ((value & type.value) != 0);
	}
	public static boolean isIntegerLiteral(int value) {
		return isOfType(value, INTEGER_LITERAL);
	}
}
